package oldFiles;
import lejos.nxt.MotorPort;
/**
 * A locomotion module with methods to drive
 * a car with two independent motors. The left motor 
 * should be connected to port C and the right motor
 * to port B.
 *  
 * @author  Ole Caprani
 * @version 17.4.08
 */
public class RaceCar 
{
    // Commands for the motors
    private final static int forward  = 1,
    						 backward = 2,
                             stop     = 3;
	                         
    private final static int MAXSPEED = 90;
    
    private final static int TURNSPEED = 80;
    
    private static MotorPort leftMotor = MotorPort.C;
    private static MotorPort rightMotor= MotorPort.B;
	
    private RaceCar()
    {	   
    } 
   
    public static void stop() 
    {
	    leftMotor.controlMotor(0,stop);
	    rightMotor.controlMotor(0,stop);
    }
   
    public static void forward(int speed)
    {
	    leftMotor.controlMotor(speed,forward);
	    rightMotor.controlMotor(speed,forward);
    }
    
    public static void turnLeft()
    {
	    leftMotor.controlMotor(TURNSPEED,forward);
	    rightMotor.controlMotor(MAXSPEED,forward);
    }
    
    public static void turnRight()
    {
	    leftMotor.controlMotor(MAXSPEED,forward);
	    rightMotor.controlMotor(TURNSPEED,forward);
    }
            
    public static void turnAroundRight()
    {
	    leftMotor.controlMotor(MAXSPEED,forward);
	    rightMotor.controlMotor(MAXSPEED,backward);
    }
    
    public static void turnAroundLeft()
    {
	    leftMotor.controlMotor(MAXSPEED,backward);
	    rightMotor.controlMotor(MAXSPEED,forward);
    }
    
}
